package com.myk.game.gobangchess.rooms.oldrooms;

import com.myk.game.gobangchess.Room;
import com.myk.game.gobangchess.constants.BoardStyleData;
import com.myk.game.gobangchess.constants.ColorCost;
import com.myk.game.gobangchess.constants.PathCost;
import com.myk.game.gobangchess.signs.ColorSign;
import com.myk.game.gobangchess.signs.GroundSign;
import com.myk.game.gobangchess.utils.GridsUtils;
import com.myk.game.gobangchess.utils.Image2Grids;

/**
 * 图片效果演示
 */
public class ImageTestRoom extends Room {

    public ImageTestRoom(String roomName) {
        super(roomName, "\t\t用于图片效果演示。","图片效果演示", BoardStyleData.getGoBangStyle(48,48), true, true);
    }

    @Override
    public String getRuleText() {
        return "用于图片效果演示";
    }

    @Override
    public String getCoordMode() {
        return "00000000";
    }

    @Override
    public String getGameInfo() {
        signList.clear();
        signList.add(new GroundSign(getIndex(0,0),getIndex(curGrids.length-1,curGrids[0].length-1), ColorCost.TABLECLOTH_COLOR, ColorCost.TABLECLOTH_COLOR,5f));


        String imageFilePath = PathCost.ROOT_PATH + "\\tools\\image\\test2.png";
        curGrids = GridsUtils.createGridsByImage(imageFilePath, curGrids.length, curGrids[0].length);


        String[][] strArr = Image2Grids.getStrArr(PathCost.ROOT_PATH + "\\tools\\image\\test2.png", 20, 20);
        for (int i = 0; i < strArr.length; i++) {
            for (int j = 0; j < strArr[i].length; j++) {
                if (strArr[i][j] != null){
                    signList.add(new ColorSign(getIndex(i,j),strArr[i][j]));
                }
            }
        }

        for (int i = 0; i < strArr.length; i++) {
            for (int j = 0; j < strArr[i].length; j++) {
                if (strArr[i][j] != null){
                    signList.add(new ColorSign(getIndex(i+20,j+20),strArr[i][j]));
                }
            }
        }
        return super.getGameInfo();
    }

    @Override
    public void doRule(int row, int col, int value) {
        curGrids[row][col] = value;
        noticeAllRefreshGameInfo();
    }
}
